<div class="banner_wrap">
<?php if(Yii::app()->user->hasFlash('changestatus')):?>
<div class="flash-success">
<?php echo Yii::app()->user->getFlash('changestatus'); ?>
</div>
<?php endif; ?>
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'banner-details-form',
	'enableAjaxValidation'=>false,
	'htmlOptions'=>array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php //echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title'); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'image'); ?>
		<?php echo $form->fileField($model,'image'); ?>
		<?php echo $form->error($model,'image'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'url'); ?>
		<?php echo $form->textField($model,'url'); ?>
		<?php echo $form->error($model,'url'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'page'); ?>
		<?php echo $form->dropDownList($model,'page', CHtml::listData(Pages::model()->findAll(), 'id', 'name'),array(
		'empty'=>'Select Page',
		'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('bannerDetails/dynamicLocationTags'), //url to call.
'update'=>'#BannerDetails_location_tags', //selector to update

))); ?>
		<?php echo $form->error($model,'page'); ?>
	</div>

	<div class="row multi-select">
		<?php echo $form->labelEx($model,'location_tags'); ?>
		<?php 
		if ($model->isNewRecord)
		echo $form->dropDownList($model,'location_tags', array(),array('multiple'=>'multiple','empty'=>'Select Page')); 
		
		else
		echo $form->dropDownList($model,'location_tags', LocationTags::LocationTagsByPageId($model->page),array('multiple'=>'multiple')); 
		
		?>
		<?php echo $form->error($model,'location_tags'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'height'); ?>
		<?php echo $form->textField($model,'height'); ?>
		<?php echo $form->error($model,'height'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'width'); ?>
		<?php echo $form->textField($model,'width'); ?>
		<?php echo $form->error($model,'width'); ?>
	</div>
    
    <div class="clear"></div>
    
    <?php if ((!$model->isNewRecord) && $model->image ){?>
		<img src="<?php echo ApplicationConfig::getImageUrl('BANNER-IMAGES', array('file_name'=>$model->image));?>" height="140px" width="180px"/>
	<?php }?>
    
    <div class="clear"></div><br />	
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
    <div class="clear"></div><br />
    <div class="link">
	<?php echo CHtml::link('Back to List',ApplicationConfig::getURL("admin", "bannerDetails", "index"),array()); ?>
	</div>
<?php 
if (!empty($model->location_tags))
{
	$arrLocations = explode(",", $model->location_tags);
	foreach ($arrLocations as $value)
	{
		if (!empty($value))
		{?>
			<script type="text/javascript">	
					
				for(var i=0;i<document.getElementById("BannerDetails_location_tags").length;i++){
				
				 if(document.getElementById("BannerDetails_location_tags").options[i].value=="<?php echo $value;?>")
				 {
				 		document.getElementById("BannerDetails_location_tags").options[i].selected=true;
				 }
				}
				</script>
		<?php }
	}	
	
}
?>

<?php $this->endWidget(); ?>

</div><!-- .banner_wrap -->